import * as types from '../../mutation-types'
import lazyLoading from './lazyLoading'
/*
import charts from './charts'
import uifeatures from './uifeatures'
import components from './components'
import tables from './tables'
*/

// show: meta.label -> name
// name: component name
// meta.label: display label
const state = {
  items: [
    {
      name: '首页',
      path: '/',
      meta: {
        link: ''
      }
    },
    {
      name: '频道管理',
      path: '/program',
      meta: {
        link: 'program/index.vue'
      },
      component: lazyLoading('program/index')
    },
    {
      name: '多画面',
      path: '/screen',
      meta: {
        link: 'screen/index.vue'
      },
      component: lazyLoading('screen/index')
    },
    {
      name: '报警查询',
      path: '/alram',
      meta: {
        link: ''
      }
    },
    {
      name: '用户管理',
      path: '/um',
      meta: {
        link: ''
      }
    },
    {
      name: '系统配置',
      path: '/sys',
      meta: {
        link: ''
      }
    }
    /*
    uifeatures,
    components,
    tables
    */
  ]
}

const mutations = {
  [types.EXPAND_MENU] (state, menuItem) {
    if (menuItem.index > -1) {
      if (state.items[menuItem.index] && state.items[menuItem.index].meta) {
        state.items[menuItem.index].meta.expanded = menuItem.expanded
      }
    } else if (menuItem.item && 'expanded' in menuItem.item.meta) {
      menuItem.item.meta.expanded = menuItem.expanded
    }
  }
}

export default {
  state,
  mutations
}
